package ControlLayer;
import ModelLayer.*;
import java.util.ArrayList;

/**
 * Write a description of class LoanCollectionController here.
 * 
 * @author (group 1(A)) 
 * @version (14-04-2011)
 */
public class LoanCollectionController
{
    // instance variables - replace the example below with your own
    private LoanCollection loanCollection;
    private AddressCtr addressCtr;
    private DVDCtr dvdCtr;
    private ArrayList<Loan> l;

    /**
     * Constructor for objects of class LoanCollectionController
     */
    public LoanCollectionController()
    {
        // initialise instance variables
        loanCollection = new LoanCollection();
        addressCtr = new AddressCtr();
        dvdCtr = new DVDCtr();
        l = new ArrayList<Loan>();    
    }
    
    /**
     * Finds a Loan
     * @return Returns a loan
     */
    public Loan findLoan(int personId, int id)
    {
        Person p = addressCtr.findPerson(personId);
        Loan loan = loanCollection.findLoan(p,id);
        return loan; 
    }
    
    /**
     * Creates a loan
     * @param id ID of the loan
     * @param date Date of the loan
     * @param periode Duration of the loan
     * @param personId Id of the person who wants to loan a DVD
     * @param dvdId Id of the DVD
     * @param status Status of the loan (+-active)
     * @param serialNumber Serial Number of the DVD copy
     * @param getDate Purchase date of the DVD copy
     * @param getPrice Purchase price of the DVD copy
     */
    public void createLoan(int id, int date, int periode, int personId, int dvdId, boolean status, int serialNumber, int getDate, int getPrice)
    {
        //if(addressCtr.findPerson(personId) != null && dvdCtr.findDVD(dvdId) != null)
        //{
            
            //int serialNumber = dvdCtr.findDVD(dvdId).getCopySerialNumber();
            //int getDate = dvdCtr.findDVD(dvdId).getCopyGetDate();
            //int getPrice = dvdCtr.findDVD(dvdId).getCopyGetPrice();
            System.out.println(addressCtr.findPerson(personId));
            l = addressCtr.findPerson(personId).createLoan(id, date, periode, status, serialNumber, getDate, getPrice);
            loanCollection.addLoans(addressCtr.findPerson(personId),  l);
            //System.out.println(dvdCtr.findDVD(dvdId));
        //}   
    }
    
    /**
     * Not implemented
     */
    public void updateLoan()
    {
    
    }
    
    /**
     * Not implemented
     */
    public void deleteLoan()
    {
    
    }

    /**
     * Not implemented
     */
    public void listAllLoans()
    {
    
    }
   
}
